import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main {

    public static User Logging() {
        System.out.println("请输入你的姓名：");
        Scanner scanner = new Scanner(System.in);
        String userName = scanner.nextLine();
        System.out.println("请输入你的身份：管理员->1  普通用户->0");
        int choise = scanner.nextInt();
        if(choise == 1) {
            return new AdminUser(userName);
        } else {
            return new NormalUser(userName);
        }
    }

    public static void main(String[] args) {
        //0.准备数据
        BookList bookList = new BookList();

        //1.登录
        User user = Logging(); //向上转型


        while(true) {
            //2.开始执行操作
            int choise = user.menu(); //选择执行哪项操作

            user.doOperation(choise, bookList);
        }
    }
}
